package com.example.axon.config;

import lombok.extern.slf4j.Slf4j;
import org.axonframework.commandhandling.CommandMessage;
import org.axonframework.eventhandling.EventMessage;
import org.axonframework.messaging.InterceptorChain;
import org.axonframework.messaging.MessageDispatchInterceptor;
import org.axonframework.messaging.MessageHandlerInterceptor;
import org.axonframework.messaging.unitofwork.UnitOfWork;

import java.util.List;
import java.util.function.BiFunction;

@Slf4j
public class MyMessageDispatchInterceptor implements MessageDispatchInterceptor<EventMessage<?>> {
    @Override
    public BiFunction<Integer, EventMessage<?>, EventMessage<?>> handle(List<? extends EventMessage<?>> eventMessages) {
        return (index, event) -> {
            log.info("Dispatching a event :: {}.", event);
            return event;
        };
    }
}